<?php

namespace backend\behaviors;

use Yii;
use backend\models\service\NovelService as Novel;

class NovelBehavior extends \yii\base\Behavior {

    public function list_for_index() {
        $dataProvider = $this->owner->getList();
        $dataProvider->setSort($this->sort_for_index());
        $dataProvider->setPagination($this->pagination_for_index());
        return $dataProvider;
    }

    /**
     * 领取页面的排序
     */
    public function sort_for_index() {
        return new \yii\data\Sort([
            'defaultOrder' => [ 'novel_update_time' => SORT_DESC],
        ]);
    }

    /**
     * 领取页面的分页
     */
    public function pagination_for_index() {
        return new \yii\data\Pagination([
            'defaultPageSize' => 10
        ]);
    }

}
